package com.ruoyi.controller.jpjs.czlrfy;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.service.jpjs.PublicService;
import com.ruoyi.service.jpjs.czlrfy.CzlrfyService;
import com.ruoyi.util.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.Map;


/**
 * 产值利润费用分析
 * author:zeo
 */

@Controller
@RequestMapping("/czlrfy")
public class CzlrfyController extends BaseController {
    @Autowired
    CzlrfyService czlrfyService;

    @Autowired
    PublicService publicService;

    private String prefix = "jpjs/czlrfy";

    @GetMapping()
    public String czlrfy(ModelMap mmap) {
        mmap.put("userComp", publicService.findUserCompAndJszb());
        return prefix + "/czlrfy";
    }

    @RequestMapping("/list")
    @ResponseBody
    public TableDataInfo list(@RequestParam Map map) {
        startPage();
        return getDataTable(czlrfyService.list(map));
    }


    @GetMapping("/edit/{id}")
    public String edit(ModelMap mmap,@PathVariable("id") String id) {
        mmap.put("data",czlrfyService.findDataById(id));
        mmap.put("userComp", publicService.findUserCompAndJszb());
        return prefix + "/edit";
    }

    @RequestMapping("/edit")
    @ResponseBody
    public AjaxResult edit(@RequestParam Map map) {
        return toAjax(czlrfyService.edit(map));
    }


    /**
     * 返回1月到当月的总产值
     * 返回1月到当月的总月末人数
     * @param map
     * @return
     */
    @RequestMapping("/getTotalOutPut")
    @ResponseBody
    public BaseResult getTotalOutPut(@RequestParam Map map){
        return czlrfyService.getTotalOutPut(map);
    }

    /**
     * 返回1月到当月的总利润
     * 返回1月到当月的总月末人数
     * @param map
     * @return
     */
    @RequestMapping("/getTotalProfit")
    @ResponseBody
    public BaseResult getTotalProfit(@RequestParam Map map){
        return czlrfyService.getTotalProfit(map);
    }

    /**
     * 返回1月到当月的总费用
     * 返回1月到当月的总月末人数
     * @param map
     * @return
     */
    @RequestMapping("/getTotalCost")
    @ResponseBody
    public BaseResult getTotalCost(@RequestParam Map map){
        return czlrfyService.getTotalCost(map);
    }
}

